define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'user/clean/index',
                    add_url: 'user/clean/add',
                    edit_url: 'user/clean/edit',
                    // del_url: 'user/clean/del',
                    multi_url: 'user/clean/multi',
                    table: 'user',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'user.id',
                columns: [
                    [
                        { checkbox: true },
                        { field: 'id', title: __('Id'), sortable: true },
                        { field: 'username', title: __('Username'), operate: 'LIKE' },
                        { field: 'mobile', title: __('手机号'), operate: 'LIKE' },
                        { field: 'city', title: __('负责区域'), operate: 'LIKE' },
                  
                        { field: 'last_month_order_num', title: __('上月配送数量'), operate: false },
                        { field: 'month_order_num', title: __('本月配送数量'), operate: false },
                        { field: 'today_num', title: __('今日配送数量'), operate: false },
                        { field: 'count_today_num', title: __('累计配送数量'), operate: false },
                        { field: 'status', title: __('Status'), formatter: Table.api.formatter.status, searchList: { normal: __('Normal'), hidden: __('Hidden') } },
                        {
                            field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,
                            // buttons: [
                            //     {
                            //         name: 'print',
                            //         title: '明细',
                            //         text: '明细',
                            //         classname: 'btn btn-primary btn-xs btn-view btn-dialog',
                            //         url: 'user/mony_log/index',//接口地址 控制器名/方法名
                            //     },
                            // ]
                        }
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});